package com.threaddemo6;

import java.util.concurrent.*;

public class NewFixedThreadPool2 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //固定长度的连接池
        ExecutorService es = Executors.newFixedThreadPool(3);

        for (int i = 0; i < 10; i++) {
            es.execute(()-> {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("执行线程" + Thread.currentThread().getName());
            });
        }

        es.shutdown();

    }
}
